<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html">
    <meta name="viewport" content="initial-scale=1.0, width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"><!-- 告诉IE浏览器用最新的引擎去渲染这个页面 -->
    <title>注册</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
</head>

<body>
    <div class="m-header hidden-lg hidden-md hidden-sm">
        <div class="nav-left">
            <div class="btn-burger navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </div>
        </div>
        <div class="wrapper___2_acE"></div>
        <!-- <div class="user-dropmenu-mask"></div> -->
        <div class="user-dropmenu" style="height:0px;opacity: 1;top: 50px;">
            <div class="search">
                <div class="input-group">
                    <span class="input-group-addon glyphicon glyphicon-search" id="basic-addon1"></span>
                    <input type="text" class="form-control" placeholder="搜索" aria-describedby="basic-addon1">
                </div>
            </div>
            <ul class="ant-menu">
                <li>
                    <div class="ant-menu-submenu-title">工作台</div>
                    <ul class="ant-menu-inline">
                        <li class="ant-menu-item"><a href="index.html" class="active">首页</a></li>
                        <li class="ant-menu-item"><a href="platform.html" class="">平台商</a></li>
                        <li class="ant-menu-item"><a href="industry.html" class="">行业雷达</a></li>
                        <li class="ant-menu-item"><a href="market.html" class="">市场雷达</a></li>
                        <li class="ant-menu-item"><a href="index.html" class="">行业活动</a></li>
                        <li class="ant-menu-item"><a href="index.html" class="">雷达广场</a></li>
                    </ul>
                </li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">帮助</a></li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">发现</a></li>
            </ul>
            <ul class="ant-menu">
                <li class="ant-menu-item"><a href="#" style="background: #fff;">个人页面</a></li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">退出</a></li>
            </ul>
        </div>
    </div>
    <div class="userBox clearfix">
        <div class="login-box clearfix">
            <div class="logo"><a href="/"><img src="img/logo.png" width="180"></a></div>
            <div class="formBox clearfix">
                <div class="hd">
                    <ul>
                        <li><a href="login.html">登录</a></li>
                        <li class="active">注册</li>
                    </ul>
                </div>
                <div class="bd">
                    <ul class="clearfix">
                        <form action="" id="myform" method="post">
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></div>
                                <input type="text" class="form-control" id="phone" name="email" placeholder="请输入邮箱">
                            </div>
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></div>
                                <input type="password" class="form-control" name="data[password]" placeholder="请输入密码，不少于6位">
                            </div>
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></div>
                                <input type="password" class="form-control" name="data[password2]" placeholder="请重复密码">
                            </div>
                            <div class="input-group smscode">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-envelope" aria-hidden="true"></i></div>
                                <input type="text" name="yzm" class="form-control" id="yzm" placeholder="邮箱验证码">
                                <a id="get-code" style="cursor:pointer">获取验证码</a>
                            </div>
                            <div class="btnsend btnreg">
                                <input type="button" id="reg-btn" class="btn-diycolor btn-block" value="立即注册">
                            </div>
                        </form>
                    </ul>
                </div>
            </div>
        </div>
        <div class="login-bg hidden-xs">
        </div>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/js-cookie/2.2.1/js.cookie.min.js"></script>
<script src="js/mine.js"></script>
<script src="js/core.js"></script>
<script>
$(function() {
    // 获取验证码
    let email;
    let password1;
    let password2;
    $("#get-code").click(function() {
        var count = 60,
            timer = null;

        email = $("input[name='email']").val();
        if ($.trim(email) == '' || $.trim(email) == '请输入邮箱' || $.trim(email) == null) {
            alert('邮箱不能为空！');
            return false;
        }
        //验证邮箱
        var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
        if (!reg.test(email)) {
            alert("邮箱格式不对！");
            return false;
        }
        Getdata(emailCode, {
            email
        }).then(res => {
            if(res.success == true){
                timer = setInterval(function(){
                    count--;
                    $("#get-code").text(count+"秒后获取验证码");
                    $('#get-code').attr("disabled", true);
                    if(count<=0){
                        clearInterval(timer);
                        $('#get-code').attr("disabled", false);
                        $("#get-code").text("点击获取验证码");
                        timer=null;
                    }
                },1000)
            }
        })

    })
    // 註冊
    $("#reg-btn").click(function() {
        password1 = $("input[name='data[password]']").val();
        password2 = $("input[name='data[password2]']").val();
        let emailCode = $("#yzm").val();
        if ($.trim(password1) == '' || $.trim(password1) == '请输入密码，不少于6位' || $.trim(password1) == null) {
            alert("密码不能为空!")
            return false;
        } else if (password1.length < 6) {
            alert("密码不能少于6位!")
            return false;
        } else if (password1 != password2) {
            alert("两次输入的密码不一致!")
            return false;
        } else if (emailCode == '') {
            alert("请输入验证码！")
            return false;
        }
        Getdata(reg, {
            emailCode,
            email,
            passWd: password1
        }).then(res => {
            if (res.success == false) {
                alert(res.msg)
            } else {
                alert("注册成功！")
            }
            // console.log(res)
        })

    })











})
</script>

</html>